<?php

require_once '../config.php';

if ($_POST) {
  sites_add($_POST['domain']);  
}

if (!empty($_GET['removeSiteId'])) {
  sites_remove($_GET['removeSiteId']);
  header('location: sites.php');
}

$administratorId = operators_get_id();
$sites = sites_get_all();

?>

<?php include dirname(__FILE__) . '/header.php' ?>
 
  <table>
    <tr>
      <td id="Sidebar">
        <h2><?php echo lang_say("Add new site") ?></h2>
        <form action="" method="POST">
          Domian<br />
          <input type="text" name="domain" /> <input type="submit" value="Add" />
        </form>        
      </td>
      <td>
        <table class="Dg">
          <h2><?php echo lang_say("Your sites") ?></h2>
          <?php foreach ($sites as $s): ?>
            <tr>
              <td class="DgCell"><?php echo $s['domain'] ?></td>
              <td class="DgCell IconCell"><a href="?removeSiteId=<?php echo $s['id'] ?>"><img src="/common/images/trash_16x16.png"></a></td>
            </tr>
          <?php endforeach ?>
        </table>
      </td>
    </tr>
  </table>  

<?php include dirname(__FILE__) . '/footer.php' ?>
